<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<HTML>
	<HEAD>
		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="${pageContext.request.contextPath}/js/public.js"></script>
		<script language="javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" href="${ pageContext.request.contextPath }/css/bootstrap.min.css" type="text/css" />
		<script src="${ pageContext.request.contextPath }/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="${ pageContext.request.contextPath }/js/bootstrap.min.js" type="text/javascript"></script>
		
		<script type="text/javascript">
			/* function showDetail(oid){
				var but = document.getElementById("but"+oid);
				var div1 = document.getElementById("div"+oid);
				if(but.value == "订单详情"){
					// 1.创建异步对象
					var xhr = createXmlHttp();
					// 2.设置监听
					xhr.onreadystatechange = function(){
						if(xhr.readyState == 4){
							if(xhr.status == 200){
								
								div1.innerHTML = xhr.responseText;
							}
						}
					}
					// 3.打开连接
					xhr.open("GET","${pageContext.request.contextPath}/adminOrder_findOrderItem.action?oid="+oid+"&time="+new Date().getTime(),true);
					// 4.发送
					xhr.send(null);
					but.value = "关闭";
				}else{
					div1.innerHTML = "";
					but.value="订单详情";
				}
				
			}
			function createXmlHttp(){
				   var xmlHttp;
				   try{ // Firefox, Opera 8.0+, Safari
				        xmlHttp=new XMLHttpRequest();
				    }
				    catch (e){
					   try{// Internet Explorer
					         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					      }
					    catch (e){
					      try{
					         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					      }
					      catch (e){}
					      }
				    }

					return xmlHttp;
				 } */
				 $(document).ready(function() {
					 var flag = $("#flag").val();
					  if( flag==1 || flag==2 ||flag==3){
						 $("tr:eq(1) td").eq(7).html("状态");
					 } 
					  if(flag==1){
						  $("tr:eq(0) td").eq(0).html("借阅列表");
					  }else if(flag==2){
						  $("tr:eq(0) td").eq(0).html("超期列表");
					  }else if(flag==3){
						  $("tr:eq(0) td").eq(0).html("历史列表");
					  }
					  
					  
				});
				 
				 
				 function showDetail(oid){
					
					 if($("#but"+oid).val()== "订单详情"){
				 $.post("${ pageContext.request.contextPath}/AdminBookBorrowServlet",{"method":"findOrderItem","bookBorrowing_id":oid},function(data){
					// alert(JSON.stringify(data));
					 
					 $(data).each(function(i,n){
						// $("#div"+oid).append("dddd");
							// 显示图片,名称,单价,数量
							
							var year = n.expeReturnTime.year+1900;
							var month = n.expeReturnTime.month+1;
							var day = n.expeReturnTime.date;
							var hours = n.expeReturnTime.hours;
							var minutes = n.expeReturnTime.minutes;
							var seconds = n.expeReturnTime.seconds;
							var year1 = n.applicationTime.year+1900;
							var month1 = n.applicationTime.month+1;
							var day1 = n.applicationTime.date;
							var hours1 = n.applicationTime.hours;
							var minutes1 = n.applicationTime.minutes;
							var seconds1 = n.applicationTime.seconds;
							if(month>12){
								month =1;
							}
							if(month1>12){
								month1 =1;
							}
							if(n.confirmationTime!=null&&n.actuReturnTime!=null){
								var year2 = n.confirmationTime.year+1900;
								var month2 = n.confirmationTime.month+1;
								var day2 = n.confirmationTime.date;
								var hours2 = n.confirmationTime.hours;
								var minutes2 = n.confirmationTime.minutes;
								var seconds2 = n.confirmationTime.seconds;
								if(month2>12){
									month2 =1;
								}
								var year3 = n.actuReturnTime.year+1900;
								var month3 = n.actuReturnTime.month+1;
								var day3 = n.actuReturnTime.date;
								var hours3 = n.actuReturnTime.hours;
								var minutes3 = n.actuReturnTime.minutes;
								var seconds3 = n.actuReturnTime.seconds;
								if(month3>12){
									month3 =1;
								}
								$("#div"+oid).append(" <div>借阅编号："+n.bookBorrowing_id+"&nbsp;</div></br><div>申请时间："+year1+"-"+month1+"-"+day1+"&nbsp;"+hours1+":"+minutes1+":"+seconds1+"&nbsp;</div></br><div>管理员确认时间："+year2+"-"+month2+"-"+day2+"&nbsp;"+hours2+":"+minutes2+":"+seconds2+"&nbsp;</div></br><div>预期归还时间："+year+"-"+month+"-"+day+"&nbsp;"+hours+":"+minutes+":"+seconds+"</div><br/><div>归还时间："+year3+"-"+month3+"-"+day3+"&nbsp;"+hours3+":"+minutes3+":"+seconds3+"</div>");

							}else if(n.confirmationTime!=null && n.actuReturnTime==null){
								var year2 = n.confirmationTime.year+1900;
								var month2 = n.confirmationTime.month+1;
								var day2 = n.confirmationTime.date;
								var hours2 = n.confirmationTime.hours;
								var minutes2 = n.confirmationTime.minutes;
								var seconds2 = n.confirmationTime.seconds;
								if(month2>12){
									month2 =1;
								}
									$("#div"+oid).append(" <div>借阅编号："+n.bookBorrowing_id+"&nbsp;</div></br><div>申请时间："+year1+"-"+month1+"-"+day1+"&nbsp;"+hours1+":"+minutes1+":"+seconds1+"&nbsp;</div></br><div>管理员确认时间："+year2+"-"+month2+"-"+day2+"&nbsp;"+hours2+":"+minutes2+":"+seconds2+"&nbsp;</div></br><div>预期归还时间："+year+"-"+month+"-"+day+"&nbsp;"+hours+":"+minutes+":"+seconds+"</div><br/>");
							}else{
									$("#div"+oid).append(" <div>借阅编号："+n.bookBorrowing_id+"&nbsp;</div></br><div>申请时间："+year1+"-"+month1+"-"+day1+"&nbsp;"+hours1+":"+minutes1+":"+seconds1+"&nbsp;</div></br><div>预期归还时间："+year+"-"+month+"-"+day+"&nbsp;"+hours+":"+minutes+":"+seconds+"</div><br/>");
							}
							
						});
					 },"json"); 
				 $("#but"+oid).val("关闭");
					 }else{
						 $("#div"+oid).html("");
						 $("#but"+oid).val("订单详情");
					 }
				 }
				 
				 
				 function dingMessage(oid){
						
					 
					 $.post("${ pageContext.request.contextPath}/AdminBookBorrowServlet",{"method":"findOrderItem","bookBorrowing_id":oid},function(data){
						// alert(JSON.stringify(data));
						 
						 $(data).each(function(i,n){
								
							});
						 },"json"); 
				
					 }
				 
		</script>
		
		<style type="text/css">
		/* 多媒体查询 ，可以解决屏幕自适应问题*/
			@media screen and (min-width: 1180px) {
    body {
        background-color: lightgreen;
    }
}
		</style>
	</HEAD>
	<body>
		<br>
		<form id="Form1" name="Form1" action="${pageContext.request.contextPath}/user/list.jsp" method="post">
			<input id ="flag" value="${ flag }" type="hidden">
			<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
				<TBODY>
					<tr>
						<td class="ta_01" align="center" bgColor="#afd1f3">
							<strong>预约列表</strong>
						</TD>
					</tr>
					
					<tr>
						<td class="ta_01" align="center" bgColor="#f5fafe">
							<table cellspacing="0" cellpadding="1" rules="all"
								bordercolor="gray" border="1" id="DataGrid1"
								style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
								<tr
									style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">

									<td align="center" width="5%">
										序号
									</td>
									<td align="center" width="12%">
										借阅图片
									</td>
									<td align="center" width="8%">
										借阅人
									</td>
									<td align="center" width="15%">
										被借图书
									</td>
									<td align="center" width="10%">
										借阅数量
									</td>
									<td align="center" width="30%">
										借阅详情
									</td>
									<td align="center" width="15%" id="cz">
										操作
									</td>
								</tr>
									<c:forEach var="o" items="${ pageBean.list }" varStatus="status">
										<tr onmouseover="this.style.backgroundColor = 'white'"
											onmouseout="this.style.backgroundColor = '#F5FAFE';">
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="5%">
												${  status.count  }
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="12%">
												<img width='60' height='65' src="${pageContext.request.contextPath}/${ o.book_image }">
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="8%">
												${  o.user_name }
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="15%">
												${ o.books_name }
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="10%">
												${ o.total }
											</td>

											<td align="center" style="HEIGHT: 22px;width:30%;">
												<input type="button" value="订单详情" id="but${ o.bookBorrowing_id }" onclick="showDetail('${ o.bookBorrowing_id}')"/>
												<div id="div${ o.bookBorrowing_id  }">
													
												</div>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="15%">						
												<c:if test="${ flag ==0 }">
													<a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=send&bookBorrowing_id=${ o.bookBorrowing_id }&flag=0"><font color="blue">确定借书</font></a>
													<a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=send&bookBorrowing_id=${ o.bookBorrowing_id }&flag=2"><font color="red">驳回</font></a>
												</c:if>		
												<c:if test="${ flag ==1 }">
													<font color="#00FF7F">借阅中。。。</font>
													<a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=send&bookBorrowing_id=${ o.bookBorrowing_id }&flag=1"><font color="blue">确定还书</font></a>
												</c:if>	
												<c:if test="${ flag ==2 }">
													<font color="red">超期${ o.exceTime }天</font>
												</c:if>		
												<c:if test="${ flag ==3 }">
													<font >图书已归还</font>
												</c:if>									
											</td>
							
										</tr>
									</c:forEach>
							</table>
						</td>
					</tr>
					<%-- <tr align="center">
						<td colspan="7">
							第<s:property value="pageBean.page"/>/<s:property value="pageBean.totalPage"/>页 
							<s:if test="pageBean.page != 1">
								<a href="${ pageContext.request.contextPath }/adminOrder_findAll.action?page=1">首页</a>|
								<a href="${ pageContext.request.contextPath }/adminOrder_findAll.action?page=<s:property value="pageBean.page-1"/>">上一页</a>|
							</s:if>
							<s:if test="pageBean.page != pageBean.totalPage">
								<a href="${ pageContext.request.contextPath }/adminOrder_findAll.action?page=<s:property value="pageBean.page+1"/>">下一页</a>|
								<a href="${ pageContext.request.contextPath }/adminOrder_findAll.action?page=<s:property value="pageBean.totalPage"/>">尾页</a>|
							</s:if>
						</td>
					</tr> --%>
				</TBODY>
			</table>
						<!-- 分页内容 -->
				<div style="text-align: center;">
				<ul class="pagination">
				
<%-- 					<li <c:if test="${ pageBean.currPage == 1 }">class="disabled"</c:if>><a href="${ pageContext.request.contextPath }/AdminUserServlet?method=findUserAllPageBean&currPage=${pageBean.currPage-1}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
 --%>
					<!-- 需要增加判断如果当前页面是第一页则不让跳转，否则进行向前 -->
					<c:if test="${ pageBean.currPage ==1 }">
						<li class="disabled"  aria-label="Previous"><span aria-hidden="true">&laquo;</span></li>
					</c:if>
					<c:if test="${ pageBean.currPage !=1 }">
						<li ><a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=findAllApp&bstatus=${bstatus}&flag=${flag}&currPage=${pageBean.currPage-1}&search=${ search}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
					</c:if>
					
					<c:forEach var="i" begin="1" end="${ pageBean.totalPage }">
						<li <c:if test="${ pageBean.currPage == i }">class="active"</c:if>><a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=findAllApp&bstatus=${bstatus}&flag=${flag}&currPage=${ i}&search=${ search}">${ i }</a></li>
					</c:forEach>
					<c:if test="${ pageBean.currPage == pageBean.totalPage }">
						<li class="disabled">
							<a href="#" aria-label="Next">
								<span aria-hidden="true">&raquo;</span>
							</a>
						</li>
					</c:if>
					<c:if test="${ pageBean.currPage != pageBean.totalPage }">
						<li>
							<a href="${ pageContext.request.contextPath }/AdminBookBorrowServlet?method=findAllApp&bstatus=${bstatus}&flag=${flag}&currPage=${pageBean.currPage+1}&search=${ search}" aria-label="Next">
								<span aria-hidden="true">&raquo;</span>
							</a>
						</li>
					</c:if>
				</ul>
			</div>
		</form>
	</body>
</HTML>

